package 进阶知识及API类库;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created By  醉美柳舞之众星捧月
 *
 * @author song
 * @date 2017/11/7 13:36
 */
public class IO流上集FilePrintWriterScannerTrywithresource {
    // IO流  input output stream
    public static void main(String[] args) {
        io();
    }

    private static PrintWriter printWriter;

    public static void io() {
        File file = new File("G:\\Resources\\sqlQQQ.txt");
        if (file.isDirectory()) {
            System.out.println("文件夹");
        }
        if (file.isFile()) {
            System.out.println("文件");
        }
        try {
            file.createNewFile();
            printWriter = new PrintWriter(file);
            printWriter.println("老王来了");
            printWriter.print("hahahahahahahahahahaha");
            printWriter.print(12345);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (printWriter != null) {
                printWriter.close();
            }
        }
    }
}
